package sfin.controller;

import java.util.ResourceBundle;

public class ControllerUtil {
	
	private ResourceBundle bundle;
	
	public ControllerUtil(ResourceBundle bundle) {
		this.bundle = bundle;
	}
	
	public String[] includeSelectOption(String[] data){
		return includeSelectOption(data, null);
	}
	
	public String[] includeSelectOption(String[] data, String firstOption){
		
		if(data == null || data.length == 0)
			return data;
		
		String[] withSelectOption = new String[data.length + 1];
		
		
		if(firstOption == null){
			withSelectOption[0] = bundle.getString("string.general.choose");	
		}else{
			withSelectOption[0] = bundle.getString(firstOption);
		}
		
		for(int i = 1; i<data.length + 1; i++){
			withSelectOption[i] = data[i - 1];
		}

		return withSelectOption;
	}
	
	
	public int normalizeOptionToShow(int option){
		return ++option;
	}
	
	public int normalizeOptionToSave(int option){
		return --option;
	}
	
}